package cn.hongxin.sap.conn.constants;

import org.apache.commons.lang.StringUtils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ErpConstant {

    public static String PARAM_TYPE_SIMPLE = getProperty("PARAM_TYPE_SIMPLE");
    public static String PARAM_TYPE_STRUCT = getProperty("PARAM_TYPE_STRUCT");
    public static String PARAM_TYPE_TABLE = getProperty("PARAM_TYPE_TABLE");
    public static String PARAM_TYPE_TB_TABLE = getProperty("PARAM_TYPE_TB_TABLE");
    public static String PARAM_TYPE_RANGE = getProperty("PARAM_TYPE_RANGE");
    public static String DATA_TYPE_BINARY_PART = getProperty("DATA_TYPE_BINARY_PART");

    public static String EXPORT_MAIN_KEY = getProperty("EXPORT_MAIN_KEY");
    public static String DATA_TYPE_TIME = "";
    public static String DATA_TYPE_DATE = "";
    public static String DATA_FROM_TYPE_VAR = "";
    public static String DATA_FROM_TYPE_SQL = "";
    public static String DATA_FROM_TYPE_FORMULA = "";

    public static String NEED_COMMIT_YES = getProperty("NEED_COMMIT_YES");
    public static String RETURN_TYPE_ERROR = "";
    public static String RETURN_TYPE_SUSPEND = "";
    public static String FUNCTION_STATUS_ENABLE = getProperty("FUNCTION_STATUS_ENABLE");

    public static String SRM_GET_TOKEN = getProperty("SRM_GET_TOKEN");
    public static String SRM_Receiving_ADD = getProperty("SRM_Receiving_ADD");
    public static String SRM_Receiving_CANCEL = getProperty("SRM_Receiving_DELETE");
    public static String USER_NAME_PRX = getProperty("USER_NAME_PRX");

    //redis-key
    public static String BA_ERP_CONNECTION = getProperty("BA_ERP_CONNECTION");
    public static String BA_ERP_FUNCTION = getProperty("BA_ERP_FUNCTION");
    public static String BA_ERP_FUNCTIONEXPORT = getProperty("BA_ERP_FUNCTIONEXPORT");
    public static String BA_ERP_FUNCTIONIMPORT = getProperty("BA_ERP_FUNCTIONIMPORT");
    public static String BA_ERP_FUNCTIONISTRUCT = getProperty("BA_ERP_FUNCTIONISTRUCT");
    public static String BA_ERP_FUNCTIONESTRUCT = getProperty("BA_ERP_FUNCTIONESTRUCT");

    public static String getProperty(String key) {
        ClassLoader loader = ErpConstant.class.getClassLoader();
        InputStream web_confInput = loader.getResourceAsStream("sapconfig.properties");
        String returnValue = "";

        try {
            Properties properties = new Properties();
            properties.load(web_confInput);
            returnValue = properties.getProperty(key);
        } catch (IOException var5) {
            var5.printStackTrace();
        }

        return returnValue;
    }

    public static String getProperty(String key, String defaultValue) {
        ClassLoader loader = ErpConstant.class.getClassLoader();
        InputStream web_confInput = loader.getResourceAsStream("sapconfig.properties");
        String returnValue = "";

        try {
            Properties properties = new Properties();
            properties.load(web_confInput);
            returnValue = properties.getProperty(key);
        } catch (IOException var6) {
            var6.printStackTrace();
        }

        if (StringUtils.isBlank(returnValue)) {
            returnValue = defaultValue;
        }

        return returnValue;
    }
}
